<template>
    <div class="header">
        <textarea cols="105" rows="4" v-model="desc" placeholder="请输入Bug的描述信息"></textarea>
        <br />
        <button class="small green button" @click="saveBug">保存</button>
    </div>
</template>

<script>

export default {
    name: 'BugHeader',
    // props: ["saveBugCallback"],
    data() {
        return {
            desc: ''
        }
    },
    methods: {
        saveBug() {
            //处理空串
            if (!this.desc.trim()) {
                return
            }

            // 创建bug对象
            let bugObj = { id: Date.now(), desc: this.desc, resolved: false }
            // 调用回调方法
            this.$emit('saveBugCallback', bugObj)
            this.desc = ''
        }
    }
}
</script>

<style scoped>
/* header */
.header {
    margin-bottom: 20px;
    margin-top: 20px;
}
</style>